package gatperdut.chato.core.messaging.packagers;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;

public abstract class GenericPackager<T> {

    @SuppressWarnings( "unchecked" )
    public JSONArray packageAll( T[] items ) {

        JSONArray selectedItemsJA = new JSONArray();

        for ( T item : items ) {
            selectedItemsJA.add( packageOne( item ) );
        }

        return selectedItemsJA;
    }

    public abstract JSONObject packageOne( T item );

    public abstract T[] toArray( Object[] objectsArray );

}
